<template>
  <div>

    <el-carousel :interval="4000" type="card" height="200px">
      <el-carousel-item v-for="item in itemList" :key="item">
        <h3 class="small">{{ item }}</h3>
      </el-carousel-item>
    </el-carousel>

    <!-- 结果列表 -->
    <el-card>
      <el-table :data="orderList" stripe style="width: 100%">
        <el-table-column label="#" width="80">
          <template slot-scope="scope">
            <!-- (pageNo-1) * pageSize + index + 1 -->
            {{
              (searchModel.pageNo - 1) * searchModel.pageSize + scope.$index + 1
            }}
          </template>
        </el-table-column>
        <el-table-column prop="orderId" label="订单id" width="180"/>
        <el-table-column prop="orderPeople" label="下单人" width="180"/>
        <el-table-column prop="orderType" label="下单类型" width="180"/>
        <el-table-column prop="orderAmount" label="下单金额（¥）" width="180"/>
        <el-table-column prop="orderTime" label="下单时间" width="180"/>
        <el-table-column prop="purchaseTime" label="支付时间" width="180"/>
        <el-table-column prop="orderStatus" label="支付状态" width="180"/>

      </el-table>
    </el-card>

    <!-- 分页组件 -->
    <el-pagination
      :current-page="searchModel.pageNo"
      :page-sizes="[5, 10, 20, 50]"
      :page-size="searchModel.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />

  </div>
</template>

<script>
// eslint-disable-next-line no-unused-vars
import tb from '@/api/tb'

export default {
  data() {
    return {
      itemList: ['小毛驴电商自学一条龙 解锁全部课程需要4000点（200元可以兑换5000点）',
        '卡密联系客服 10元100点 25元400点 50元1000点 200元5000点',
        '1次起3个店铺 2个月内做9家店铺 2个月内不回本 课程费全退'],
      formLabelWidth: '130px',
      dialogFormVisible: false,
      title: '',
      total: 0,
      searchModel: {
        pageNo: 1,
        pageSize: 5
      },
      orderList: []
    }
  },
  created() {
    this.getOrderList()
  },
  methods: {
    handleSizeChange(pageSize) {
      this.searchModel.pageSize = pageSize
      this.getOrderList()
    },
    handleCurrentChange(pageNo) {
      this.searchModel.pageNo = pageNo
      this.getOrderList()
    },
    getOrderList() {
      tb.getOrderList(this.searchModel).then((response) => {
        this.orderList = response.data.rows
        this.total = response.data.total
      })
    }
  }
}
</script>

<style>
#search .el-input {
  width: 200px;
  margin-right: 10px;
}

.el-dialog .el-input {
  width: 85%;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 20px;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}
</style>
